import { CHANGE_FOUCS_STATUS,KEYWORD_LIST } from "./constant";
//引入immutable库,mutable"可变的"的意思,immutable"不可变的"意思 
import { fromJS } from "immutable";
//通过fromJS方法传入一个对象,得到一个immutable对象
const defaultStore = fromJS({
  focused: false,
  list:["罗小黑","刺客伍六七"]
});
const reduceHandler = (store = defaultStore, action) => {
  switch(action.type){
    case CHANGE_FOUCS_STATUS:
      // immutable对象的set方法,会结合之前immutable对象的值和要设置的值,返回一个全新的对象。
      return store.set("focused",action.value); 
    case KEYWORD_LIST:
      return store.set("list",action.list);
    default:
      return store;
  }
};
export default reduceHandler;

